package com.sand.sc.upms.user;

import com.sand.sc.upms.user.feign.UserFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * com.sand.sc.eureka.server
 *
 * @author yaohaobing
 * @version 1.0.0
 * @description app认证服务
 * @date 2019/11/27 19:22
 */
@RestController
public class UserController {

    @Autowired
    private UserFeign userFeign;


    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/user")
    public String getUser(String name) {
        Map<String, String> params = new HashMap<>(10);
        params.put("name", name);
        return restTemplate.getForObject("http://eureka-client/hello", String.class, params);
    }

    @RequestMapping("/user/feign")
    public String getUserByFeign(String name) {
        return userFeign.getUser(name);
    }
}
